#!/usr/bin/python
# -*- coding: UTF-8 -*-

from Scripts.Excel import ExcelConfigElementData

#
# the line data
# @author Lee
#
class Class:
    #all of element datas in a line
    _datas : None

    #
    # the constructed process
    #
    def __init__(self):
        self._datas = []
    
    #
    # Adds the data
    # @param [dataName] the data name
    # @param [dataType] the data type
    # @param [dataValue] the data value
    #
    def AddData(self, dataName, dataType, dataValue):
        if None == self._datas:
            return
        
        for i in range(len(self._datas)):
            findData = self._datas[i]
            findDataName = findData.GetName()
            if findDataName == dataName:
                return
        
        data = ExcelConfigElementData.Class(dataName, dataType, dataValue)
        self._datas.append(data)

    #
    # Gets the data count of a line
    # @return the data count of a line
    #
    def GetCount(self):
        if None == self._datas:
            return 0
        
        dataCount = len(self._datas)
        return dataCount

    #
    # Gets the data with a index
    # @param [index] a specified index
    #
    def GetData(self, index):
        if None == self._datas:
            return None

        dataCount = len(self._datas)
        if index < 0 or index >= dataCount:
            return None
        
        data = self._datas[index]
        return data

    #
    # Checks whether the data is empty
    # @return whether the data is empty 
    #
    def IsEmpty(self):
        if None == self._datas:
            return True
        
        for i in range(len(self._datas)):
            findData = self._datas[i]
            findDataValue = findData.IsEmpty()
            if False == findDataValue:
                return False

        return True